const router = require('koa-router')(),
      mysql = require('mysql2/promise'),
      { admin } = require('../models');

router.prefix('/api/kdoing/admin');

router.get('/getalladmins', async (ctx, next) => {
  ctx.body = await admin.getAllAdmins();
});
router.get('/getaadmin/:admin_account', async (ctx, next) => {
  const {admin_account} = ctx.params;
  ctx.body = await admin.getAAdmin(admin_account);
});

router.post('/login', async (ctx, next) => {
  var { admin_account, password } = ctx.request.body;
  ctx.body = await admin.ifLogin(admin_account, password);
});

module.exports = router;
